package org.opu.db.obj.vis.ui.client.tablerenders;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.opu.db.obj.vis.domain.domains.AbstractEntity;
import org.opu.db.obj.vis.domain.domains.ObjectEntry;
import org.opu.db.obj.vis.domain.domains.ObjectPriority;
import org.opu.db.obj.vis.ui.client.BeanView;

public class TableRenderObject implements TableRender<ObjectEntry> {

	public static final Object[] COLUMN_NAMES;
	public static final Class<?>[] TYPES = new Class<?>[] {
        String.class,
        String.class,
        String.class
    };

    static {
//        PublicationI18N i18n = new PublicationI18N();
        COLUMN_NAMES = new Object[]{
//                    i18n.get("secondName", "Second name"),
//                    i18n.get("name", "Name"),
//                    i18n.get("lastName", "Last name"),
//                    i18n.get("isStudent", "Student")
            "Schema", "Table", "Description"
                };
    }

	@Override
	public Class<ObjectEntry> getRenderingClass() {
		return ObjectEntry.class;
	}

	@Override
	public void rendView(Collection<? extends AbstractEntity> beans, BeanView view) {
		Object[][] rowData = new Object[beans.size()][4];

		int i = 0;
		for (AbstractEntity tb : beans) {
			ObjectEntry bean = (ObjectEntry) tb;
			rowData[i][0] = bean.getId().getSchemaName();
			rowData[i][1] = bean.getId().getTableName();
			rowData[i][2] = bean.getDescription();
            
            ArrayList<ObjectPriority> prioritys = bean.getPrioritys();
//			rowData[i][3] = prioritys; // TODO:
            i++;
		}
		view.setContent(COLUMN_NAMES, TYPES, rowData);
	}

}
